package com.list88zhu.common;

import com.list88zhu.common.rxhttp.http.BaseApi;
import com.list88zhu.common.rxhttp.http.HttpOnNextListener;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;

import java.util.HashMap;
import java.util.Map;

import retrofit2.Retrofit;
import rx.Observable;

/**
 * projectName NOS_Android
 * date 2017/7/11
 * description com.vjwealth.vjcarclub.http
 */

public abstract class AppBaseApi extends BaseApi {

    protected Map<String, String> params;

    public AppBaseApi(HttpOnNextListener listener, RxAppCompatActivity activity) {
        super(listener, activity);
        setShowProgress(true);
        setCancel(true);
        setCache(false);
        params = new HashMap<>();
        params.put("key", "7f5ce5813f494795b1639348ab844e4a");
    }

    @Override
    public Observable getObservable(Retrofit retrofit) {
        AppApi loginApi = retrofit.create(AppApi.class);
        return getFetchApiObservable(loginApi);
    }

    public abstract Observable getFetchApiObservable(AppApi appApi);

    public Map<String, String> getParams() {
        return params;
    }

    public void setParams(Map<String, String> params) {
        this.params.putAll(params);
    }
}
